home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / emulator / bsvc-1.000 / bsvc-1 / bsvc-1.0.4 / src / SimHector / devices / RAM.tcl < prev    next >
Encoding:
Tcl/Tk script  |  1995-07-26  |  3.8 KB  |  106 lines

  1. #!/usr/local/bin/wish -f
  2. ###############################################################################
  3. # $Id: RAM.tcl,v 1.2 1994/08/22 07:39:34 bmott Exp $
  4. ###############################################################################
  5. # This Tcl script gets the setup information for the RAM device.
  6. #
  7. # Notes: - All Procedures and global variables begin with "DeviceSetup".  This
  8. #          should be true for all device scripts.
  9. #        - The toplevel window should be .device for all device scripts.
  10. #        - The script must return a valid argument for the device's
  11. #          constructor. (i.e. "BaseAddress=00000000 Size=00000000")
  12. #        - If the cancel button is pressed the empty string should be
  13. #          returned
  14. #        - All device scripts should be modal dialogs
  15. #
  16. # Copyright (c) 1993
  17. # By: Bradford W. Mott
  18. # October 30,1993
  19. ###############################################################################
  20. # $Log: RAM.tcl,v $
  21. # Revision 1.2  1994/08/22  07:39:34  bmott
  22. # Made the dialog a little more user friendly and changed the names of
  23. # some of the device arguments
  24. #
  25. # Revision 1.1  1994/02/18  20:15:27  bmott
  26. # Initial revision
  27. #
  28. ###############################################################################
  29.  
  30. proc DeviceSetupGetValues {} {
  31.   set base [.device.inputs.entry.address get]
  32.   set size [.device.inputs.entry.size get]
  33.  
  34.   set result "BaseAddress=$base Size=$size"
  35.   return "$result"
  36. }
  37.  
  38. proc DeviceSetupCheckValues {} {
  39.   set base [.device.inputs.entry.address get]
  40.   set size [.device.inputs.entry.size get]
  41.  
  42.   if {[regexp {^[0-9A-Fa-f]+$} $base] && [regexp {^[0-9A-Fa-f]+$} $size]} {
  43.     destroy .device 
  44.   } else {
  45.     
  46.   }
  47. }
  48.  
  49. ###############################################################################
  50. # This is the procedure the User Interface calls
  51. ###############################################################################
  52. proc DeviceSetup {} {
  53.   global DeviceSetupReturnValue
  54.  
  55.   catch {destroy .device}
  56.  
  57.   toplevel .device
  58.   wm title .device "RAM Setup"
  59.   wm iconname .device "RAM Setup"
  60.  
  61.   message .device.message \
  62.     -text "Please enter the base address and size of the RAM.\n\nAll values are in hexadecimal!" \
  63.     -width 3i -justify left
  64.  
  65.   frame .device.inputs -relief ridge -borderwidth 2
  66.     frame .device.inputs.label
  67.       label .device.inputs.label.address -text "Base Address:"
  68.       label .device.inputs.label.size -text "Size:"
  69.       pack .device.inputs.label.address -side top 
  70.       pack .device.inputs.label.size -side right
  71.     frame .device.inputs.entry
  72.       entry .device.inputs.entry.address -width 10 -relief sunken
  73.       bind .device.inputs.entry.address \
  74.           <Return> { focus .device.inputs.entry.size }
  75.       entry .device.inputs.entry.size -width 10 -relief sunken
  76.       bind .device.inputs.entry.size \
  77.           <Return> { focus .device.inputs.entry.address }
  78.       pack .device.inputs.entry.address -side top -fill x -expand 1 -pady 2
  79.       pack .device.inputs.entry.size -side top -fill x -expand 1 -pady 2
  80.     pack .device.inputs.label -side left 
  81.     pack .device.inputs.entry -side left -fill x -expand 1 -padx 2
  82.  
  83.   frame .device.buttons
  84.     button .device.buttons.ok -text "Okay" \
  85.       -command {set DeviceSetupReturnValue [DeviceSetupGetValues]
  86.                 DeviceSetupCheckValues}
  87.     button .device.buttons.cancel -text "Cancel" \
  88.       -command {set DeviceSetupReturnValue ""; destroy .device}
  89.     pack .device.buttons.ok -side left -expand 1 -fill x -padx 4
  90.     pack .device.buttons.cancel -side right -expand 1 -fill x -padx 4
  91.  
  92.   pack .device.message -side top -fill x -pady 4 -padx 4
  93.   pack .device.inputs -side top -fill x -pady 2 -padx 4 -ipady 2
  94.   pack .device.buttons -side top -fill x -pady 4
  95.  
  96.   # Set input focus to the first entry widget
  97.   tkwait visibility .device
  98.   focus .device.inputs.entry.address
  99.  
  100.   # Make this a modal dialog
  101.   grab set .device
  102.   tkwait window .device
  103.  
  104.   return $DeviceSetupReturnValue
  105. }
  106.